package org.jmat.domain.dao.impl;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;

import org.jmat.domain.dao.PersonDao;
import org.jmat.domain.entities.Person;
import org.springframework.stereotype.Repository;

@Repository
public class PersonDaoJpa implements PersonDao{

	@PersistenceContext(type = PersistenceContextType.EXTENDED)
	private EntityManager em;
	
	public void createPerson(Person p) {
		this.em.persist(p);
	}


	public void deletePerson(Person p) {
		this.em.remove(p);
	}

	
	public Person findById(Integer id) {
		return (Person)this.em.find(Person.class, id);
	}

}
